package ToYesterday.replaceBackSpace_05;

public class SolutionByTwoPointers {
    public void solution(char[] strs){
        int sum = 0;
        int length=0;
        for (int i =0 ;strs[i]!='\0';i++){
            length++;
            if (strs[i]==' ')sum+=3;
            else sum+=1;
        }
        while (sum>-1&&length>-1){
            if (strs[length]!=' '){
                strs[sum]=strs[length];
                length--;
                sum--;
            }else {
                strs[sum]='0';
                strs[sum-1]='2';
                strs[sum-2]='%';
                sum=sum-3;
                length--;
            }
        }
    }
}
